package view.diaLogView;

import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextPaint;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.example.administrator.text.HomeActivity;
import com.example.administrator.text.R;
import app.MyApplication;
import data.SharedPreferencesUtils;
import util.HomeUtil;
import util.JumpActivityUtils;

/**
 * Created by Administrator on 2016/6/30.
 * 挤出的退出提示框
 */
public class CrowdRetunDialog extends Dialog{
    private CrowdRetunDialog mRetunDialog;
    private Context mContext;

    protected CrowdRetunDialog(Context context, boolean cancelable, OnCancelListener cancelListener) {
        super(context, cancelable, cancelListener);
    }

    public CrowdRetunDialog(Context context) {
        super(context, R.style.upoad_dialog);
        this.mContext = context;
        mRetunDialog = this;
    }

    @Override protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        init();
    }

    private void init() {
        ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
        params.width = mContext.getResources().getDisplayMetrics().widthPixels;
        LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View mView = inflater.inflate(R.layout.crowdretun_dialog, null);
        TextView textView1 = (TextView)mView.findViewById(R.id.crowdretun_oktv);  //确定
        TextView textView2 = (TextView)mView.findViewById(R.id.textView_crowdretun);
        TextPaint textPaint = textView2.getPaint();
        SharedPreferencesUtils.setParam(mContext,HomeUtil.mNetworkingTime,0);
        textPaint.setFakeBoldText(true);
        String fwq = (String) SharedPreferencesUtils.getParam(mContext, HomeUtil.mFWQ,"");
        MyApplication.getApp().setFWQString(fwq);
        textView1.setOnClickListener(new View.OnClickListener() {
            @Override public void onClick(View v) {
                Intent intent = new Intent(HomeActivity.mAction);
                intent.putExtra("wifi","finish");
                mContext.sendBroadcast(intent);
                JumpActivityUtils.getInstance().jumEntrtPrompt(mContext);
                mRetunDialog.dismiss();
                ((Activity) mContext).finish();
            }});

        setContentView(mView, params);
    }
}
